<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>
<input type="text"/>
<input type="button" value="加密"/>
<p></p>
<input type="button" value="解密"/>
<p></p>
<script>
var aInp = document.getElementsByTagName("input");
var aP = document.getElementsByTagName("p");
aInp[1].onclick = function (){
	var str = aInp[0].value;
	var str1 = "";
	for(var i=0;i<str.length;i++){
		str1 += String.fromCharCode(str.charCodeAt(i)+i);
	}
	aP[0].innerHTML = str1;
}
aInp[2].onclick = function (){
	var str = aP[0].innerHTML;
	var str1 = "";
	for(var i=0;i<str.length;i++){
		str1 += String.fromCharCode(str.charCodeAt(i)-i);
	}
	aP[1].innerHTML = str1;
}
</script>
</body>
</html>
